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

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

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

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

g = A("g")
a = B("a")
c = C("c")
h = D("h")

g.p = a
g.z = a
g.y = a
a.p = h
c.x = g
c.v = h
h.s = g
h.u = c
assert h.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: B = None
        self.y: B = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
c = C("c")
h = D("h")

g.p = a
g.z = a
g.y = a
a.p = h
c.x = g
c.v = h
h.s = g
h.u = c
assert h.u.v.u.txt == "c"