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

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

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

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

n = A("n")
f = B("f")
h = C("h")
g = D("g")
b = A("b")
l = D("l")
d = B("d")

n.y = h
f.r = b
h.s = n
h.r = n
g.t = b
g.v = h
b.y = h
l.t = b
l.v = h
d.r = n
assert g.t.y.r.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

n = A("n")
f = B("f")
h = C("h")
g = D("g")
b = A("b")
l = D("l")
d = B("d")

n.y = h
f.r = b
h.s = n
h.r = n
g.t = b
g.v = h
b.y = h
l.t = b
l.v = h
d.r = n
assert g.t.y.r.y.s.y.txt == "h"