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

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

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

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

m = A("m")
f = B("f")
n = C("n")
b = D("b")
c = D("c")
k = B("k")

m.u = c
f.s = k
f.p = k
n.u = c
n.x = k
n.s = k
b.p = m
b.q = m
b.v = c
c.p = m
c.q = m
c.v = b
k.s = f
k.p = f
assert c.q.u.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

m = A("m")
f = B("f")
n = C("n")
b = D("b")
c = D("c")
k = B("k")

m.u = c
f.s = k
f.p = k
n.u = c
n.x = k
n.s = k
b.p = m
b.q = m
b.v = c
c.p = m
c.q = m
c.v = b
k.s = f
k.p = f
assert c.q.u.v.q.txt == "m"