class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: B = 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.u: B = None
        self.t: D = None
        self.txt = txt

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

m = A("m")
g = B("g")
b = C("b")
n = D("n")
l = D("l")

m.u = l
m.p = g
g.y = m
b.u = g
b.t = l
n.v = b
n.w = l
n.t = l
n.u = m
l.v = b
l.w = n
l.t = n
l.u = m
assert m.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: B = 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.u: B = None
        self.t: D = None
        self.txt = txt

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

m = A("m")
g = B("g")
b = C("b")
n = D("n")
l = D("l")

m.u = l
m.p = g
g.y = m
b.u = g
b.t = l
n.v = b
n.w = l
n.t = l
n.u = m
l.v = b
l.w = n
l.t = n
l.u = m
assert m.u.w.u.txt == "m"