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

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

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

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

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

d.u = b
d.y = i
l.p = i
l.x = g
i.x = d
i.t = k
i.q = k
i.p = l
g.w = b
g.s = b
g.u = d
k.x = d
k.t = i
k.q = i
k.p = l
b.u = d
b.y = k
assert d.u.u.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: C = None
        self.txt = txt

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

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

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

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

d.u = b
d.y = i
l.p = i
l.x = g
i.x = d
i.t = k
i.q = k
i.p = l
g.w = b
g.s = b
g.u = d
k.x = d
k.t = i
k.q = i
k.p = l
b.u = d
b.y = k
assert d.u.u.y.x.txt == "d"