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

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

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

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

g = A("g")
k = B("k")
n = C("n")
l = D("l")
h = A("h")

g.y = k
g.s = k
g.u = l
g.t = n
k.u = l
n.r = l
l.r = g
h.y = k
h.s = k
h.u = l
h.t = n
assert l.r.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: D = None
        self.t: C = None
        self.s: B = None
        self.txt = txt

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

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

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

g = A("g")
k = B("k")
n = C("n")
l = D("l")
h = A("h")

g.y = k
g.s = k
g.u = l
g.t = n
k.u = l
n.r = l
l.r = g
h.y = k
h.s = k
h.u = l
h.t = n
assert l.r.y.u.txt == "l"