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

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

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

d = A("d")
m = B("m")
i = C("i")
h = C("h")
b = A("b")
j = B("j")
e = A("e")
f = B("f")

d.y = j
d.o = b
d.t = e
m.r = h
m.q = f
i.q = m
h.q = f
b.y = f
b.o = e
b.t = d
j.r = h
j.q = f
e.y = j
e.o = d
e.t = b
f.r = i
f.q = j
assert f.q.q.r.q.q.q.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: A = None
        self.t: A = None
        self.txt = txt

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

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

d = A("d")
m = B("m")
i = C("i")
h = C("h")
b = A("b")
j = B("j")
e = A("e")
f = B("f")

d.y = j
d.o = b
d.t = e
m.r = h
m.q = f
i.q = m
h.q = f
b.y = f
b.o = e
b.t = d
j.r = h
j.q = f
e.y = j
e.o = d
e.t = b
f.r = i
f.q = j
assert f.q.q.r.q.q.q.q.r.txt == "i"