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

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

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

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

k = A("k")
e = B("e")
b = C("b")
d = D("d")
j = B("j")
f = B("f")
g = C("g")

k.r = e
k.p = d
e.o = d
e.t = d
e.z = j
b.v = e
b.o = f
b.s = k
d.y = g
j.o = d
j.t = d
j.z = f
f.o = d
f.t = d
f.z = j
g.v = e
g.o = j
g.s = k
assert g.o.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.p: D = None
        self.txt = txt

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

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

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

k = A("k")
e = B("e")
b = C("b")
d = D("d")
j = B("j")
f = B("f")
g = C("g")

k.r = e
k.p = d
e.o = d
e.t = d
e.z = j
b.v = e
b.o = f
b.s = k
d.y = g
j.o = d
j.t = d
j.z = f
f.o = d
f.t = d
f.z = j
g.v = e
g.o = j
g.s = k
assert g.o.z.o.txt == "d"