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

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

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

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

b = A("b")
c = B("c")
k = C("k")
n = D("n")
a = D("a")
h = C("h")
i = C("i")

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

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

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

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

b = A("b")
c = B("c")
k = C("k")
n = D("n")
a = D("a")
h = C("h")
i = C("i")

b.r = h
c.u = h
c.w = b
c.v = b
k.q = c
k.p = c
k.y = b
n.r = k
n.t = c
n.v = i
n.z = a
a.r = i
a.v = i
a.t = c
a.z = n
h.q = c
h.p = c
h.y = b
i.q = c
i.p = c
i.y = b
assert a.v.p.w.txt == "b"