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

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

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

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

l = A("l")
a = B("a")
e = C("e")
g = D("g")
n = D("n")

l.u = a
a.p = l
e.x = g
e.v = g
e.t = l
g.u = l
g.r = e
g.w = n
n.u = l
n.r = e
n.w = g
assert e.t.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

l = A("l")
a = B("a")
e = C("e")
g = D("g")
n = D("n")

l.u = a
a.p = l
e.x = g
e.v = g
e.t = l
g.u = l
g.r = e
g.w = n
n.u = l
n.r = e
n.w = g
assert e.t.u.p.txt == "l"