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

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.y: D = None
        self.s: A = None
        self.txt = txt

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

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

a = A("a")
j = B("j")
d = C("d")
h = D("h")
e = B("e")
k = B("k")
n = A("n")

a.u = d
a.w = h
j.t = d
j.y = h
j.s = a
d.r = n
h.p = n
e.t = d
e.y = h
e.s = n
k.t = d
k.y = h
k.s = a
n.u = d
n.w = h
assert k.t.r.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.y: D = None
        self.s: A = None
        self.txt = txt

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

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

a = A("a")
j = B("j")
d = C("d")
h = D("h")
e = B("e")
k = B("k")
n = A("n")

a.u = d
a.w = h
j.t = d
j.y = h
j.s = a
d.r = n
h.p = n
e.t = d
e.y = h
e.s = n
k.t = d
k.y = h
k.s = a
n.u = d
n.w = h
assert k.t.r.u.r.txt == "n"