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

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

b = A("b")
c = B("c")
d = C("d")
j = D("j")
f = E("f")
h = A("h")
m = C("m")

b.y = h
c.z = j
c.t = j
c.v = b
d.q = j
d.y = h
j.p = d
f.s = c
f.o = j
f.t = h
h.y = b
m.q = j
m.y = b
assert h.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

b = A("b")
c = B("c")
d = C("d")
j = D("j")
f = E("f")
h = A("h")
m = C("m")

b.y = h
c.z = j
c.t = j
c.v = b
d.q = j
d.y = h
j.p = d
f.s = c
f.o = j
f.t = h
h.y = b
m.q = j
m.y = b
assert h.y.y.y.y.y.y.txt == "h"