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

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

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: C = None
        self.txt = txt

n = A("n")
d = B("d")
b = C("b")
c = D("c")
g = C("g")
l = B("l")
k = C("k")

n.u = g
n.z = g
n.y = c
d.u = b
d.x = l
b.x = k
b.v = n
b.t = l
c.r = l
c.z = g
g.x = b
g.v = n
g.t = d
l.u = b
l.x = d
k.x = g
k.v = n
k.t = l
assert d.x.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: C = None
        self.y: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: C = None
        self.txt = txt

n = A("n")
d = B("d")
b = C("b")
c = D("c")
g = C("g")
l = B("l")
k = C("k")

n.u = g
n.z = g
n.y = c
d.u = b
d.x = l
b.x = k
b.v = n
b.t = l
c.r = l
c.z = g
g.x = b
g.v = n
g.t = d
l.u = b
l.x = d
k.x = g
k.v = n
k.t = l
assert d.x.x.u.txt == "b"