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

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

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

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

g = A("g")
h = B("h")
d = C("d")
j = D("j")
l = B("l")

g.o = j
h.v = d
d.x = h
d.p = h
j.t = d
l.v = d
assert g.o.t.x.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

g = A("g")
h = B("h")
d = C("d")
j = D("j")
l = B("l")

g.o = j
h.v = d
d.x = h
d.p = h
j.t = d
l.v = d
assert g.o.t.x.v.p.txt == "h"