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

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

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

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

h = A("h")
g = B("g")
c = C("c")
b = D("b")
e = A("e")

h.p = g
h.w = b
h.x = c
g.v = e
g.o = b
c.x = e
b.v = c
b.s = c
b.u = h
b.y = h
e.p = g
e.w = b
e.x = c
assert e.x.x.x.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: D = None
        self.x: C = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
c = C("c")
b = D("b")
e = A("e")

h.p = g
h.w = b
h.x = c
g.v = e
g.o = b
c.x = e
b.v = c
b.s = c
b.u = h
b.y = h
e.p = g
e.w = b
e.x = c
assert e.x.x.x.x.p.txt == "g"