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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: A = None
        self.u: B = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
c = C("c")
j = D("j")
a = B("a")
e = A("e")
b = A("b")

k.x = e
k.r = e
k.q = c
k.z = c
g.s = a
g.u = a
g.r = b
c.p = e
j.v = g
j.p = e
j.w = b
a.s = g
a.u = g
a.r = b
e.x = b
e.q = c
e.z = c
e.r = k
b.x = e
b.q = c
b.z = c
b.r = k
assert c.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: C = None
        self.r: A = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: A = None
        self.u: B = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
c = C("c")
j = D("j")
a = B("a")
e = A("e")
b = A("b")

k.x = e
k.r = e
k.q = c
k.z = c
g.s = a
g.u = a
g.r = b
c.p = e
j.v = g
j.p = e
j.w = b
a.s = g
a.u = g
a.r = b
e.x = b
e.q = c
e.z = c
e.r = k
b.x = e
b.q = c
b.z = c
b.r = k
assert c.p.q.p.txt == "e"