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

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

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

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

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

c.y = j
c.v = j
j.p = c
b.r = c
b.z = c
b.t = g
g.r = j
g.o = b
assert g.o.t.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.txt = txt

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

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

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

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

c.y = j
c.v = j
j.p = c
b.r = c
b.z = c
b.t = g
g.r = j
g.o = b
assert g.o.t.r.p.txt == "c"