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

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

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

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

j = A("j")
g = B("g")
l = C("l")
c = D("c")
m = D("m")
i = B("i")

j.o = i
g.v = l
g.t = l
l.p = j
c.u = j
m.u = j
i.v = l
i.t = l
assert c.u.o.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
l = C("l")
c = D("c")
m = D("m")
i = B("i")

j.o = i
g.v = l
g.t = l
l.p = j
c.u = j
m.u = j
i.v = l
i.t = l
assert c.u.o.v.p.txt == "j"