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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: A = None
        self.q: D = None
        self.p: C = None
        self.txt = txt

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

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

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

i = A("i")
g = B("g")
j = C("j")
b = D("b")
a = E("a")
f = B("f")

i.q = a
i.w = j
g.u = b
g.q = b
g.w = i
g.p = j
j.x = a
b.y = i
b.z = g
b.q = f
a.o = j
a.t = i
f.u = b
f.q = b
f.w = i
f.p = j
assert f.u.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.w: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: A = None
        self.q: D = None
        self.p: C = None
        self.txt = txt

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

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

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

i = A("i")
g = B("g")
j = C("j")
b = D("b")
a = E("a")
f = B("f")

i.q = a
i.w = j
g.u = b
g.q = b
g.w = i
g.p = j
j.x = a
b.y = i
b.z = g
b.q = f
a.o = j
a.t = i
f.u = b
f.q = b
f.w = i
f.p = j
assert f.u.q.u.q.txt == "f"