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

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.s: D = None
        self.o: C = None
        self.u: D = 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.q: A = None
        self.v: C = None
        self.x: C = None
        self.r: B = None
        self.txt = txt

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

b.y = g
h.x = n
h.s = l
h.u = l
h.o = g
n.r = k
l.q = k
l.v = n
l.x = g
l.r = d
g.r = b
k.y = g
d.x = n
d.s = l
d.u = l
d.o = g
assert d.x.r.y.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.s: D = None
        self.o: C = None
        self.u: D = 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.q: A = None
        self.v: C = None
        self.x: C = None
        self.r: B = None
        self.txt = txt

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

b.y = g
h.x = n
h.s = l
h.u = l
h.o = g
n.r = k
l.q = k
l.v = n
l.x = g
l.r = d
g.r = b
k.y = g
d.x = n
d.s = l
d.u = l
d.o = g
assert d.x.r.y.r.y.r.txt == "b"