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

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

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

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

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

c = A("c")
d = B("d")
j = C("j")
f = D("f")
k = E("k")

c.q = j
c.u = j
c.y = f
d.y = j
d.x = c
d.u = k
j.q = f
f.v = d
f.q = j
f.u = c
f.z = c
f.x = k
k.z = c
assert c.q.q.v.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

c = A("c")
d = B("d")
j = C("j")
f = D("f")
k = E("k")

c.q = j
c.u = j
c.y = f
d.y = j
d.x = c
d.u = k
j.q = f
f.v = d
f.q = j
f.u = c
f.z = c
f.x = k
k.z = c
assert c.q.q.v.x.y.txt == "f"