class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
m = C("m")
l = B("l")
n = C("n")
b = C("b")
d = A("d")
k = C("k")
a = B("a")
j = A("j")

f.y = c
c.q = d
c.t = a
m.q = a
m.y = j
l.q = d
l.t = c
n.q = c
n.y = j
b.q = a
b.y = f
d.y = c
k.q = a
k.y = f
a.q = d
a.t = l
j.y = c
assert j.y.q.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
m = C("m")
l = B("l")
n = C("n")
b = C("b")
d = A("d")
k = C("k")
a = B("a")
j = A("j")

f.y = c
c.q = d
c.t = a
m.q = a
m.y = j
l.q = d
l.t = c
n.q = c
n.y = j
b.q = a
b.y = f
d.y = c
k.q = a
k.y = f
a.q = d
a.t = l
j.y = c
assert j.y.q.y.q.txt == "d"