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

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

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

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

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

g.u = k
j.z = k
j.u = d
j.p = c
k.p = c
k.v = d
c.o = k
c.y = d
c.u = g
d.z = k
d.u = j
d.p = c
assert g.u.v.u.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

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

g.u = k
j.z = k
j.u = d
j.p = c
k.p = c
k.v = d
c.o = k
c.y = d
c.u = g
d.z = k
d.u = j
d.p = c
assert g.u.v.u.z.p.txt == "c"