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

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

f = A("f")
l = B("l")
g = C("g")
m = D("m")
j = E("j")
k = B("k")
h = D("h")

f.z = g
l.q = g
l.t = f
l.y = f
l.v = h
g.t = j
g.u = f
m.r = j
j.o = g
j.q = g
k.q = g
k.t = f
k.y = f
k.v = m
h.r = j
assert h.r.o.t.o.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

f = A("f")
l = B("l")
g = C("g")
m = D("m")
j = E("j")
k = B("k")
h = D("h")

f.z = g
l.q = g
l.t = f
l.y = f
l.v = h
g.t = j
g.u = f
m.r = j
j.o = g
j.q = g
k.q = g
k.t = f
k.y = f
k.v = m
h.r = j
assert h.r.o.t.o.u.z.txt == "g"