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

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

class C:
    def __init__(self, txt: str):
        self.o: F = None
        self.x: B = None
        self.v: A = None
        self.w: D = None
        self.txt = txt

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

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

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

b = A("b")
l = B("l")
g = C("g")
a = D("a")
k = E("k")
c = F("c")
d = E("d")

b.r = g
b.p = g
l.r = b
l.q = a
g.o = c
g.x = l
g.v = b
g.w = a
a.v = g
a.s = g
k.v = b
c.r = a
d.v = b
assert k.v.p.o.r.s.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.p: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: F = None
        self.x: B = None
        self.v: A = None
        self.w: D = None
        self.txt = txt

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

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

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

b = A("b")
l = B("l")
g = C("g")
a = D("a")
k = E("k")
c = F("c")
d = E("d")

b.r = g
b.p = g
l.r = b
l.q = a
g.o = c
g.x = l
g.v = b
g.w = a
a.v = g
a.s = g
k.v = b
c.r = a
d.v = b
assert k.v.p.o.r.s.x.r.txt == "b"