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

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

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.x: A = None
        self.txt = txt

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

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

g = A("g")
l = B("l")
b = C("b")
c = D("c")
h = E("h")
f = A("f")
j = E("j")
d = B("d")
e = A("e")

g.z = h
l.t = c
l.r = f
b.r = h
b.x = g
c.u = g
h.t = l
f.z = j
j.t = d
d.t = c
d.r = f
e.z = h
assert j.t.t.u.z.t.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.x: A = None
        self.txt = txt

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

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

g = A("g")
l = B("l")
b = C("b")
c = D("c")
h = E("h")
f = A("f")
j = E("j")
d = B("d")
e = A("e")

g.z = h
l.t = c
l.r = f
b.r = h
b.x = g
c.u = g
h.t = l
f.z = j
j.t = d
d.t = c
d.r = f
e.z = h
assert j.t.t.u.z.t.t.u.txt == "g"