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

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

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

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

m = A("m")
c = B("c")
g = C("g")
l = D("l")
h = C("h")

m.y = c
c.v = m
c.y = m
g.r = c
g.u = l
g.w = l
g.q = h
l.u = c
l.s = m
h.r = c
h.u = l
h.w = l
h.q = g
assert g.r.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

m = A("m")
c = B("c")
g = C("g")
l = D("l")
h = C("h")

m.y = c
c.v = m
c.y = m
g.r = c
g.u = l
g.w = l
g.q = h
l.u = c
l.s = m
h.r = c
h.u = l
h.w = l
h.q = g
assert g.r.v.y.txt == "c"