class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

f = A("f")
d = B("d")
n = C("n")
e = B("e")
a = C("a")
b = B("b")
j = A("j")

f.q = n
d.t = n
d.o = a
n.s = f
e.t = a
e.o = a
a.s = j
b.t = n
b.o = n
j.q = n
assert j.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

f = A("f")
d = B("d")
n = C("n")
e = B("e")
a = C("a")
b = B("b")
j = A("j")

f.q = n
d.t = n
d.o = a
n.s = f
e.t = a
e.o = a
a.s = j
b.t = n
b.o = n
j.q = n
assert j.q.s.q.txt == "n"