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

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: E = None
        self.r: E = None
        self.u: C = None
        self.p: A = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: E = None
        self.r: E = None
        self.u: C = None
        self.p: A = None
        self.txt = txt

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

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

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

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

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