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

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.u: C = None
        self.w: C = None
        self.o: C = None
        self.txt = txt

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

l = A("l")
d = B("d")
g = C("g")
c = D("c")
a = C("a")
i = D("i")

l.p = i
d.y = l
g.v = l
g.u = a
g.w = a
g.o = a
c.w = i
c.t = g
a.v = l
a.u = g
a.w = g
a.o = g
i.w = c
i.t = g
assert g.w.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.u: C = None
        self.w: C = None
        self.o: C = None
        self.txt = txt

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

l = A("l")
d = B("d")
g = C("g")
c = D("c")
a = C("a")
i = D("i")

l.p = i
d.y = l
g.v = l
g.u = a
g.w = a
g.o = a
c.w = i
c.t = g
a.v = l
a.u = g
a.w = g
a.o = g
i.w = c
i.t = g
assert g.w.u.v.txt == "l"