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

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

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

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

g = A("g")
n = B("n")
k = C("k")
f = D("f")
b = A("b")

g.u = n
g.t = f
g.y = b
n.w = k
k.v = g
k.s = g
k.r = f
k.x = b
f.y = n
f.q = k
b.u = n
b.t = f
b.y = g
assert g.t.y.w.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: D = None
        self.y: A = None
        self.txt = txt

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

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

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

g = A("g")
n = B("n")
k = C("k")
f = D("f")
b = A("b")

g.u = n
g.t = f
g.y = b
n.w = k
k.v = g
k.s = g
k.r = f
k.x = b
f.y = n
f.q = k
b.u = n
b.t = f
b.y = g
assert g.t.y.w.x.t.txt == "f"