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

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

class C:
    def __init__(self, txt: str):
        self.z: F = None
        self.t: D = None
        self.q: E = None
        self.o: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.p: B = None
        self.z: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: A = None
        self.txt = txt

i = A("i")
d = B("d")
g = C("g")
m = D("m")
e = E("e")
b = F("b")
j = B("j")
a = B("a")

i.t = b
d.o = i
g.z = b
g.t = m
g.q = e
g.o = i
m.w = b
m.p = a
m.z = e
e.t = g
b.z = e
b.p = i
j.o = i
a.o = i
assert d.o.t.p.t.p.t.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: F = None
        self.t: D = None
        self.q: E = None
        self.o: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.p: B = None
        self.z: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: A = None
        self.txt = txt

i = A("i")
d = B("d")
g = C("g")
m = D("m")
e = E("e")
b = F("b")
j = B("j")
a = B("a")

i.t = b
d.o = i
g.z = b
g.t = m
g.q = e
g.o = i
m.w = b
m.p = a
m.z = e
e.t = g
b.z = e
b.p = i
j.o = i
a.o = i
assert d.o.t.p.t.p.t.p.t.txt == "b"