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

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

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

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

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

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

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

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

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

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

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

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

c.q = b
c.o = a
a.z = j
a.x = c
a.q = c
a.p = f
j.v = c
j.o = a
j.u = a
g.y = j
g.x = b
b.q = a
b.z = a
b.o = g
f.y = j
f.x = b
assert f.x.o.x.txt == "b"