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

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

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

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

k = A("k")
h = B("h")
c = C("c")
i = D("i")
e = B("e")
j = A("j")
b = C("b")

k.t = c
k.q = c
h.w = j
c.z = i
c.q = i
c.p = i
c.r = e
i.w = j
i.u = e
e.w = j
j.t = b
j.q = b
b.z = i
b.q = i
b.p = i
b.r = h
assert c.p.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.q: C = None
        self.txt = txt

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

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

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

k = A("k")
h = B("h")
c = C("c")
i = D("i")
e = B("e")
j = A("j")
b = C("b")

k.t = c
k.q = c
h.w = j
c.z = i
c.q = i
c.p = i
c.r = e
i.w = j
i.u = e
e.w = j
j.t = b
j.q = b
b.z = i
b.q = i
b.p = i
b.r = h
assert c.p.w.q.txt == "b"